//
//  ChatImgCell.m
//  MQTT-Demo
//
//  Created by zhaoguoteng on 2020/4/11.
//  Copyright © 2020 zhaoguoteng. All rights reserved.
//

#import "ChatImgCell.h"
#import <SDWebImage/SDWebImage.h>

@interface ChatImgCell ()

@property(nonatomic, strong) IBOutlet UIView *bgView;
@property(nonatomic, strong) IBOutlet UIImageView *contentImgView;
@property(nonatomic, strong) IBOutlet UIImageView *avatarImgView;

@property(nonatomic, strong) IBOutlet NSLayoutConstraint *imgWidth;
@property(nonatomic, strong) IBOutlet NSLayoutConstraint *imgHeight;

//https://upload-images.jianshu.io/upload_images/106726-7ab04a26a06de361.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240

@end

@implementation ChatImgCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
}

- (void)setModel:(ChatImgModel *)model {
    _model = model;
    
    if (model.width > model.height) {
        self.imgWidth.constant = 170.0;
        self.imgHeight.constant = model.height / model.width * 170.0;
    } else {
        self.imgWidth.constant = model.width / model.height * 170.0;
        self.imgHeight.constant = 170.0;
    }
    
    [self.contentImgView sd_setImageWithURL: [NSURL URLWithString:model.url]];
    [self.avatarImgView sd_setImageWithURL: [NSURL URLWithString:@"https://upload-images.jianshu.io/upload_images/106726-628c9155ae7b82fd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"]];
}

@end
